package com.example.prison.mapper;

import com.example.prison.entity.PushRecord;
import com.example.prison.entity.PushRecord;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @author jiang
* @description 针对表【push_record】的数据库操作Mapper
* @createDate 2023-06-13 09:32:29
* @Entity com.example.prison.entity.PushRecord
*/
@Mapper
public interface PushRecordMapper extends BaseMapper<PushRecord> {

    @Select("select * from push_record order by id desc")
    List<PushRecord> get();

    @Insert("insert into push_record(alarm_level, push_personnel, note, push_time) " +
            "values (#{alarmLevel}, #{pushPersonnel}, #{note}, #{pushTime})")
    int add(PushRecord record);

    @Select("select * from push_record where id = #{id}")
    PushRecord getById(@Param("id") Integer id);

    @Select("select * from push_record where push_personnel like concat('%',#{pushPersonnel},'%') order by id desc")
    List<PushRecord> getByPushPersonnel(@Param("pushPersonnel") String pushPersonnel);

    @Select("select * from push_record where push_time between #{beginTime} and #{endTime} order by id desc")
    List<PushRecord> getByTime(@Param("beginTime") String beginTime, @Param("endTime") String endTime);

    @Select("select * from push_record where alarm_level like concat('%',#{alarmLevel},'%') order by id desc")
    List<PushRecord> getByLevel(@Param("alarmLevel") String alarmLevel);

}




